From: Bilal Elmoussaoui Date: Wed, 15 Apr 2026 07:37:00 +0000 (+0200) Subject: Prefer g_steal_pointer where possible X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~10^2^2~47 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=1a78a80cf396fc3a8c2b336f50f59b95055eb110;p=gnome-shell.git Prefer g_steal_pointer where possible Part-of: --- diff --git a/src/calendar-server/gnome-shell-calendar-server.c b/src/calendar-server/gnome-shell-calendar-server.c index 4cd28d1c2..0b2f88eb7 100644 --- a/src/calendar-server/gnome-shell-calendar-server.c +++ b/src/calendar-server/gnome-shell-calendar-server.c @@ -402,8 +402,7 @@ app_notify_events_removed (App *app) GVariantBuilder builder; GSList *ids, *link; - ids = app->notify_ids; - app->notify_ids = NULL; + ids = g_steal_pointer (&app->notify_ids); print_debug ("Emitting EventsRemoved with %d ids", g_slist_length (ids)); diff --git a/src/shell-global.c b/src/shell-global.c index 97b46e5cc..fb8ea9a13 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -1273,8 +1273,7 @@ run_leisure_functions (gpointer data) if (global->leisure_closures == NULL) return G_SOURCE_REMOVE; - closures = global->leisure_closures; - global->leisure_closures = NULL; + closures = g_steal_pointer (&global->leisure_closures); for (iter = closures; iter; iter = iter->next) { diff --git a/src/st/croco/cr-om-parser.c b/src/st/croco/cr-om-parser.c index e9fdcd27b..380bd4e5e 100644 --- a/src/st/croco/cr-om-parser.c +++ b/src/st/croco/cr-om-parser.c @@ -249,8 +249,7 @@ end_font_face (CRDocHandler * a_this) if (!stmts) goto error; - ctxt->stylesheet->statements = stmts; - stmts = NULL; + ctxt->stylesheet->statements = g_steal_pointer (&stmts); ctxt->cur_stmt = NULL; return; @@ -330,8 +329,7 @@ charset (CRDocHandler * a_this, CRString * a_charset, } return; } - ctxt->stylesheet->statements = stmt2; - stmt2 = NULL; + ctxt->stylesheet->statements = g_steal_pointer (&stmt2); } static void @@ -404,8 +402,7 @@ end_page (CRDocHandler * a_this, ctxt->cur_stmt); if (stmt) { - ctxt->stylesheet->statements = stmt; - stmt = NULL; + ctxt->stylesheet->statements = g_steal_pointer (&stmt); ctxt->cur_stmt = NULL; } @@ -477,8 +474,7 @@ end_media (CRDocHandler * a_this, GList * a_media_list) ctxt->cur_media_stmt = NULL; } - ctxt->stylesheet->statements = stmts; - stmts = NULL; + ctxt->stylesheet->statements = g_steal_pointer (&stmts); ctxt->cur_stmt = NULL ; ctxt->cur_media_stmt = NULL ; @@ -526,16 +522,14 @@ import_style (CRDocHandler * a_this, stmt2 = cr_statement_append (ctxt->cur_stmt, stmt); if (!stmt2) goto error; - ctxt->cur_stmt = stmt2; - stmt2 = NULL; + ctxt->cur_stmt = g_steal_pointer (&stmt2); stmt = NULL; } else { stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt); if (!stmt2) goto error; - ctxt->stylesheet->statements = stmt2; - stmt2 = NULL; + ctxt->stylesheet->statements = g_steal_pointer (&stmt2); stmt = NULL; } diff --git a/src/st/croco/cr-parser.c b/src/st/croco/cr-parser.c index 864e287e7..ea196ec3f 100644 --- a/src/st/croco/cr-parser.c +++ b/src/st/croco/cr-parser.c @@ -1364,8 +1364,7 @@ cr_parser_parse_attribute_selector (CRParser * a_this, ENSURE_PARSING_COND (status == CR_OK && token && token->type == IDENT_TK); - result->name = token->u.str; - token->u.str = NULL; + result->name = g_steal_pointer (&token->u.str); cr_token_destroy (token); token = NULL; @@ -1401,11 +1400,9 @@ cr_parser_parse_attribute_selector (CRParser * a_this, ENSURE_PARSING_COND (status == CR_OK && token); if (token->type == IDENT_TK) { - result->value = token->u.str; - token->u.str = NULL; + result->value = g_steal_pointer (&token->u.str); } else if (token->type == STRING_TK) { - result->value = token->u.str; - token->u.str = NULL; + result->value = g_steal_pointer (&token->u.str); } else { status = CR_PARSING_ERROR; goto error; @@ -1734,8 +1731,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) add_sel = cr_additional_sel_new_with_type (ID_ADD_SELECTOR); - add_sel->content.id_name = token->u.str; - token->u.str = NULL; + add_sel->content.id_name = g_steal_pointer (&token->u.str); cr_parsing_location_copy (&add_sel->location, @@ -1760,8 +1756,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) add_sel = cr_additional_sel_new_with_type (CLASS_ADD_SELECTOR); - add_sel->content.class_name = token->u.str; - token->u.str = NULL; + add_sel->content.class_name = g_steal_pointer (&token->u.str); add_sel_list = cr_additional_sel_append @@ -1826,12 +1821,10 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) if (token->type == IDENT_TK) { pseudo->type = IDENT_PSEUDO; - pseudo->name = token->u.str; - token->u.str = NULL; + pseudo->name = g_steal_pointer (&token->u.str); found_sel = TRUE; } else if (token->type == FUNCTION_TK) { - pseudo->name = token->u.str; - token->u.str = NULL; + pseudo->name = g_steal_pointer (&token->u.str); cr_parser_try_to_skip_spaces_and_comments (a_this); status = cr_parser_parse_ident @@ -1873,8 +1866,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) if (status == CR_OK && found_sel == TRUE) { cr_parser_try_to_skip_spaces_and_comments (a_this); - sel->add_sel = add_sel_list; - add_sel_list = NULL; + sel->add_sel = g_steal_pointer (&add_sel_list); if (*a_sel == NULL) { *a_sel = sel; @@ -2151,8 +2143,7 @@ cr_parser_parse_function (CRParser * a_this, goto error; if (token && token->type == FUNCTION_TK) { - *a_func_name = token->u.str; - token->u.str = NULL; + *a_func_name = g_steal_pointer (&token->u.str); } else { status = CR_PARSING_ERROR; goto error; @@ -3223,8 +3214,7 @@ cr_parser_parse_declaration (CRParser * a_this, cr_term_append_term (*a_expr, expr); expr = NULL; } else { - *a_expr = expr; - expr = NULL; + *a_expr = g_steal_pointer (&expr); } cr_parser_clear_errors (a_this); @@ -3730,8 +3720,7 @@ cr_parser_parse_media (CRParser * a_this) ENSURE_PARSING_COND (status == CR_OK && token && token->type == IDENT_TK); - medium = token->u.str; - token->u.str = NULL; + medium = g_steal_pointer (&token->u.str); cr_token_destroy (token); token = NULL; @@ -3898,8 +3887,7 @@ cr_parser_parse_page (CRParser * a_this) ENSURE_PARSING_COND (status == CR_OK && token); if (token->type == IDENT_TK) { - page_selector = token->u.str; - token->u.str = NULL; + page_selector = g_steal_pointer (&token->u.str); cr_token_destroy (token); token = NULL; } else { @@ -4149,8 +4137,7 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value, status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token); ENSURE_PARSING_COND (status == CR_OK && token && token->type == STRING_TK); - charset_str = token->u.str; - token->u.str = NULL; + charset_str = g_steal_pointer (&token->u.str); cr_token_destroy (token); token = NULL; @@ -4163,10 +4150,7 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value, cr_token_destroy (token); token = NULL; - if (charset_str) { - *a_value = charset_str; - charset_str = NULL; - } + *a_value = g_steal_pointer (&charset_str); PRIVATE (a_this)->state = CHARSET_PARSED_STATE; return CR_OK; diff --git a/src/st/croco/cr-tknzr.c b/src/st/croco/cr-tknzr.c index ad800f93b..2c273c953 100644 --- a/src/st/croco/cr-tknzr.c +++ b/src/st/croco/cr-tknzr.c @@ -756,8 +756,7 @@ cr_tknzr_parse_string (CRTknzr * a_this, CRString ** a_str) if (status == CR_OK) { if (*a_str == NULL) { - *a_str = str; - str = NULL; + *a_str = g_steal_pointer (&str); } else { (*a_str)->stryng = g_string_append_len ((*a_str)->stryng, @@ -1207,8 +1206,7 @@ cr_tknzr_parse_uri (CRTknzr * a_this, } if (str) { if (*a_str == NULL) { - *a_str = str; - str = NULL; + *a_str = g_steal_pointer (&str); } else { g_string_append_len ((*a_str)->stryng, @@ -1982,8 +1980,7 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk) CR_BAD_PARAM_ERROR); if (PRIVATE (a_this)->token_cache) { - *a_tk = PRIVATE (a_this)->token_cache; - PRIVATE (a_this)->token_cache = NULL; + *a_tk = g_steal_pointer (&PRIVATE (a_this)->token_cache); return CR_OK; } @@ -2683,8 +2680,7 @@ cr_tknzr_parse_token (CRTknzr * a_this, enum CRTokenType a_type, case TIME_TK: case FREQ_TK: if (token->extra_type == a_et) { - *((CRNum **) a_res) = token->u.num; - token->u.num = NULL; + *((CRNum **) a_res) = g_steal_pointer (&token->u.num); status = CR_OK; } break; diff --git a/src/st/st-icon.c b/src/st/st-icon.c index d55ca419e..be4297668 100644 --- a/src/st/st-icon.c +++ b/src/st/st-icon.c @@ -474,8 +474,7 @@ st_icon_finish_update (StIcon *icon) if (priv->pending_texture) { - priv->icon_texture = priv->pending_texture; - priv->pending_texture = NULL; + priv->icon_texture = g_steal_pointer (&priv->pending_texture); clutter_actor_set_x_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_add_child (CLUTTER_ACTOR (icon), priv->icon_texture); diff --git a/src/st/st-widget.c b/src/st/st-widget.c index 72c7e8adc..ea162ec59 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -524,11 +524,7 @@ st_widget_style_changed_internal (StWidget *widget, StThemeNode *old_theme_node = NULL; priv->is_style_dirty = TRUE; - if (priv->theme_node) - { - old_theme_node = priv->theme_node; - priv->theme_node = NULL; - } + old_theme_node = g_steal_pointer (&priv->theme_node); /* update the style only if we are mapped */ if (clutter_actor_is_mapped (CLUTTER_ACTOR (widget)))